package com.example.API;

import java.util.Date;

public class DateClass {
    public static void main(String[] args) {
        //表示电脑中的当前时间
        Date date = new Date();
        System.out.println(date);   //Sun Aug 18 10:54:34 CST 2024

        //从计算机的时间原点开始，过了指定毫秒的时间
        Date date1 = new Date(0L);
        System.out.println(date1);  //Thu Jan 01 08:00:00 CST 1970

        Date date2 = new Date(3600L * 1000);
        System.out.println(date2);  //Thu Jan 01 09:00:00 CST 1970

        method(date);

        date.setTime(0L);
        System.out.println(date);   //Thu Jan 01 08:00:00 CST 1970

    }

    private static void method(Date date) {
        //获取时间对象的毫秒值-------当前时间的毫秒值
        long time = date.getTime();
        System.out.println(time);

        long time2 = System.currentTimeMillis();
        System.out.println(time2);
    }
}
